#include<bits/stdc++.h>
#define ll long long
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(!x)
        putchar('0');
    char F[200];
    int tmp=x>0?x:-x;
    if(x<0)
        putchar('-');
    int cnt=0;
    while(tmp>0)
        F[cnt++]=tmp%10+'0',tmp/=10;
    while(cnt>0)
        putchar(F[--cnt]);
}
const int N=2e5+5,mod=998244353;
int n,h[N],to[N<<1],nxt[N<<1];
int cnt,a[N],deg[N],res[N];
bool flag;
inline void add_(int a,int b)
{
	to[++cnt]=b;
	nxt[cnt]=h[a];
	h[a]=cnt;
	deg[a]++;
	return;
}
inline void clear()
{
	for(int i=1;i<=n;i++)
	{
		h[i]=deg[i]=0;
		cnt=0;
	}
	return;
}
inline void dfs(int x,int fa)
{
	res[x]=0;
	if(deg[x]==1)
		res[x]=a[x];
	else 
	{
		int Mx=0;
		for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
		{
			if(y^fa)
			{
				dfs(y,x);
				res[x]+=res[y];
				Mx=max(Mx,res[y]);
			}
		}
		if(!flag)
			return;
		int Mst=res[x]/2;
		if(Mx>res[x]-Mx)
			Mst=res[x]-Mx;
		if(res[x]<a[x])
			return flag=0,void();
		int del=res[x]-a[x];
		if(del>Mst)
			return flag=0,void();
		res[x]-=del*2;
	}
}
inline void solve()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=2;i<=n;i++)
	{
		int x=read(),y=read();
		add_(x,y);
		add_(y,x);
	}
	if(n==1)
		return puts(a[1]?"NO":"YES"),void();
	if(n==2)
		return puts(a[1]==a[2]?"YES":"NO"),clear(),void();
	for(int i=1;i<=n;i++)
		if(deg[i]>1)
			return flag=1,dfs(i,0),puts((!res[i]&&flag)?"YES":"NO"),clear(),void();
}
signed main()
{
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	int T=read();
	while(T--)
		solve();
	return 0;
}	
